package gortepfeil;

/**
 * This class represents a line between two points.
 * It is the direct connection between both points. 
 * @author Nikolai Gorte, Matthias Pfeil
 *
 */
public class Line 
{
	/**
	 * start and end point of the line
	 */
	private Point startPoint;
	private Point endPoint;
	
	/**
	 * Constructor
	 * @param startPoint beginning of the line
	 * @param endPoint end of the line
	 */
	public Line(Point startPoint, Point endPoint) 
	{
		this.startPoint = startPoint;
		this.endPoint = endPoint;
	}
	
	/**
	 * Gets the start point of a line.
	 * @return start point
	 */
	public Point getStartPoint() 
	{
		return startPoint;
	}
	
	/**
	 * Gets the end point of a line
	 * @return end point
	 */
	public Point getEndPoint() 
	{
		return endPoint;
	}
	
	/**
	 * Sets the start point of a line
	 * @param startPoint new start point
	 */
	public void setStartPoint(Point startPoint) 
	{
		this.startPoint = startPoint;
	}
	
	/**
	 * Sets end point of a line
	 * @param endPoint new end point
	 */
	public void setEndPoint(Point endPoint) 
	{
		this.endPoint = endPoint;
	}
	
	/**
	 * Calculates the length of a line
	 * @return
	 */
	public double getLength() 
	{
		//System.out.println("Length of line: "+this.startPoint.calcDistanceTo(this.endPoint));
		return this.startPoint.calcDistanceTo(this.endPoint);
	}
	
	/**
	 * Converts a line to a string for displaying on a console
	 */
	@Override
	public String toString() 
	{
		return this.startPoint+" -> "+this.endPoint;
	}

}
